package com.conero.yangsu.controller.system;

import com.conero.yangsu.lib.FeedbackData;
import com.conero.yangsu.service.ModuleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/system/systemModule")
public class SystemModuleController {
    private final ModuleService moduleService;

    public SystemModuleController(ModuleService moduleService) {
        this.moduleService = moduleService;
    }

    @GetMapping("/{module}/config")
    public FeedbackData config(@PathVariable String module) {
        if (module.isEmpty()) {
            return FeedbackData.error("请求参数有误");
        }
        HashMap<String, Object> config = moduleService.getConfigByModule(module);
        if (config == null) {
            return FeedbackData.error("未找到相信的模块！");
        }
        return FeedbackData.success(config);
    }
}
